home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / mslang / timtst / timtst.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-15  |  3.3 KB  |  119 lines

  1. //***************************************************************************
  2. //
  3. // Simple string output benchmark.
  4. // Using MFC Time Class
  5. //
  6. //
  7. // Written by: Karl Weller
  8. // CI$: [74620,2112]
  9. //
  10. //***************************************************************************
  11. #define _DOS
  12. #include "stdio.h"
  13. #include "stdlib.h"
  14. #include "conio.h"
  15. #include "time.h"
  16. #include "iostream.h"
  17. #include "afx.h"
  18.  
  19. char far *scr;    // Display pointer for memory output
  20.  
  21. //**************************************************************************
  22. //
  23. // Set up char far *scr to point to the correct video address.
  24. // Clear the display.
  25. //
  26. //**************************************************************************
  27. void cldisp(void )
  28. {
  29.     register int i=0;
  30.  
  31.     if ((*((char far *)(0L + 0x410)) & 0x30) != 0x30) 
  32.         scr = (char far *)0xb8000000;                  // Color
  33.     else
  34.         scr = (char far *)0xb0000000;                  // Mono
  35.  
  36.     while (i<4000) {
  37.         *(scr+(i++*2)) = ' ';
  38.     }
  39. }
  40.  
  41. //**************************************************************************
  42. //
  43. // Display the string 
  44. //
  45. //**************************************************************************
  46. void disp(CString s)
  47. {
  48.     register int i=0;
  49.     while (s[i]) {
  50.         *(scr+(i*2)) = s[i];
  51.         ++i;
  52.     }
  53. }
  54.  
  55. int main()
  56. {
  57.     int cnt = 0;
  58.     CTime t1;
  59.     CString s;
  60.  
  61.     cldisp();
  62.     while(!kbhit()) {
  63.         cnt = 0;
  64.         // Locate the cursor at 0,0
  65.         _asm {
  66.             mov ah,02
  67.             xor dx,dx
  68.             xor bx,bx
  69.             int 10h
  70.         }
  71.         t1 = CTime::GetCurrentTime();
  72.         while(t1 == CTime::GetCurrentTime()); // Wait for the time to change
  73.         t1 = CTime::GetCurrentTime();
  74.         while(t1 == CTime::GetCurrentTime()) { // Loop for a second
  75.             s = t1.Format("%A, %B %d, %Y %I:%M:%S%p");
  76.             disp(s);  // Display using video ram
  77.             ++cnt;
  78.         }
  79.         cout << "\nNumber of times it was displayed using memory out " << cnt << endl;
  80.  
  81.         cnt = 0;
  82.         // Locate the cursor at 0,0
  83.         _asm {
  84.             mov ah,02
  85.             xor dx,dx
  86.             xor bx,bx
  87.             int 10h
  88.         }
  89.         t1 = CTime::GetCurrentTime();
  90.         while(t1 == CTime::GetCurrentTime());
  91.         t1 = CTime::GetCurrentTime();
  92.         while(t1 == CTime::GetCurrentTime()) {
  93.             s = t1.Format("%A, %B %d, %Y %I:%M:%S%p");
  94.             printf("%s\r",s);
  95.             ++cnt;
  96.         }
  97.         cout << "\n\nNumber of times it was displayed using printf " << cnt << endl;
  98.  
  99.         cnt = 0;
  100.         // Locate the cursor at 0,0
  101.         _asm {
  102.             mov ah,02
  103.             xor dx,dx
  104.             xor bx,bx
  105.             int 10h
  106.         }
  107.         t1 = CTime::GetCurrentTime();
  108.         while(t1 == CTime::GetCurrentTime());
  109.         t1 = CTime::GetCurrentTime();
  110.         while(t1 == CTime::GetCurrentTime()) {
  111.             s = t1.Format("%A, %B %d, %Y %I:%M:%S%p");
  112.             cout << s << "\r";
  113.             ++cnt;
  114.         }
  115.         cout << "\n\n\nNumber of times it was displayed using cout " << cnt << endl;
  116.     }
  117.     return(0);
  118. }
  119.